package com.example.finalapplication;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;
import java.util.Map;

public class MineAdapterOne extends ArrayAdapter {

    public MineAdapterOne(@NonNull Context context, int resource, @NonNull List objects) {
        super(context, resource, objects);
    }

        @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        View itemView = convertView;
        if (itemView == null) {
            itemView = LayoutInflater.from(getContext()).inflate(R.layout.item_one,
                    parent,
                    false);

        }

        Map<String, String> map = (Map<String, String>) getItem(position);

        TextView title = (TextView)itemView.findViewById(R.id.title);
        TextView detail = (TextView)itemView.findViewById(R.id.detail);

        title.setText("币种："+ map.get("cname"));
        detail.setText("价格："+ map.get("cval"));

        return itemView;
    }
}